class TikTokUserModel {
  final String username;
  final bool isVerified;
  final int likesCount;
  final String openId;
  final String unionId;
  final String bioDescription;
  final int followingCount;
  final int videoCount;
  final String avatarLargeUrl;
  final String avatarUrl100;
  final int followerCount;
  final String profileDeepLink;
  final String avatarUrl;
  final String displayName;

  TikTokUserModel({
    required this.username,
    required this.isVerified,
    required this.likesCount,
    required this.openId,
    required this.unionId,
    required this.bioDescription,
    required this.followingCount,
    required this.videoCount,
    required this.avatarLargeUrl,
    required this.avatarUrl100,
    required this.followerCount,
    required this.profileDeepLink,
    required this.avatarUrl,
    required this.displayName,
  });

  // Convert JSON to TikTokUser
  factory TikTokUserModel.fromJson(Map<String, dynamic> json) {
    return TikTokUserModel(
      username: json['username'] ?? '',
      isVerified: json['is_verified'] ?? false,
      likesCount: json['likes_count'] ?? 0,
      openId: json['open_id'] ?? '',
      unionId: json['union_id'] ?? '',
      bioDescription: json['bio_description'] ?? '',
      followingCount: json['following_count'] ?? 0,
      videoCount: json['video_count'] ?? 0,
      avatarLargeUrl: json['avatar_large_url'] ?? '',
      avatarUrl100: json['avatar_url_100'] ?? '',
      followerCount: json['follower_count'] ?? 0,
      profileDeepLink: json['profile_deep_link'] ?? '',
      avatarUrl: json['avatar_url'] ?? '',
      displayName: json['display_name'] ?? '',
    );
  }

  // Convert TikTokUser to JSON (optional)
  Map<String, dynamic> toJson() {
    return {
      'username': username,
      'is_verified': isVerified,
      'likes_count': likesCount,
      'open_id': openId,
      'union_id': unionId,
      'bio_description': bioDescription,
      'following_count': followingCount,
      'video_count': videoCount,
      'avatar_large_url': avatarLargeUrl,
      'avatar_url_100': avatarUrl100,
      'follower_count': followerCount,
      'profile_deep_link': profileDeepLink,
      'avatar_url': avatarUrl,
      'display_name': displayName,
    };
  }

  @override
  String toString() {
    return 'TikTokUserModel{'
        'username: $username, '
        'isVerified: $isVerified, '
        'likesCount: $likesCount, '
        'openId: ${openId.isNotEmpty ? "[redacted]" : "empty"}, '
        'unionId: ${unionId.isNotEmpty ? "[redacted]" : "empty"}, '
        'bioDescription: ${bioDescription.isNotEmpty ? "'$bioDescription'" : "empty"}, '
        'followingCount: $followingCount, '
        'videoCount: $videoCount, '
        'followerCount: $followerCount, '
        'displayName: $displayName, '
        'avatarUrl: ${avatarUrl.isNotEmpty ? "[URL]" : "empty"}, '
        'avatarUrl100: ${avatarUrl100.isNotEmpty ? "[URL]" : "empty"}, '
        'avatarLargeUrl: ${avatarLargeUrl.isNotEmpty ? "[URL]" : "empty"}, '
        'profileDeepLink: ${profileDeepLink.isNotEmpty ? "[URL]" : "empty"}'
        '}';
  }
}
